import axios from 'axios'
import {BaseUrl} from './url'
import {message} from 'antd'


const  API = (url,data,type='GET')=>{
    
    return new Promise((resolve,reject)=>{
        let promise =null
        if(type==='POST'){
            promise = axios({
                url:BaseUrl+url,
                data,
                method:'POST'
            })
        }else{
            promise = axios({
                url:BaseUrl+url,
                params:data
            })
        }
        promise.then((response)=>{
            resolve(response.data)
        })
        .catch(err=>{
            message.error(err)
        })
    })
}
export default API